#include "wx/wx.h"
#include "wx/socket.h"
#include <wx/tokenzr.h>

#ifndef CLIENTFRAME_HPP
#define CLIENTFRAME_HPP

class HangmanApp : public wxApp
{
	virtual bool OnInit();
};

DECLARE_APP(HangmanApp)

class HangManWindow : public wxWindow
 {
 public:
    HangManWindow(wxWindow* parent);

    void OnPaint(wxPaintEvent& event);
 private:
   DECLARE_EVENT_TABLE()
};

BEGIN_EVENT_TABLE(HangManWindow, wxWindow)
    EVT_PAINT(HangManWindow::OnPaint)
END_EVENT_TABLE()

class ClientFrame : public wxFrame
{
private:
	wxTextCtrl *_tbLetter;
	wxButton *_btGuess;
	wxStaticText *_lblWord;
	wxStaticText *_lblNbFailure;
	wxMenu *_menu;
	

	wxBoxSizer *sizerMain;
	
	wxString *_guess;
	wxString *_IPServer;
	wxSocketBase *_socket;

	int nbFailure;
	HangManWindow* window;
	


public:
	int victory;
	wxString *_wordToShow;
	ClientFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
	void OnClick_btGuess(wxCommandEvent& event);
	void OnClick_menuQuit(wxCommandEvent& event);
	void OnClick_menuNew(wxCommandEvent& event);
	void OnClick_menuNewIP(wxCommandEvent& event);
	void OnSocketEvent(wxSocketEvent& event);

	void ConnectToServer();
	void SendGuessToServer(wxString& guess);
	void setGuess(wxString& guess);
	void setIPServer(wxString& IP);
	int getNbFailure();
	
	DECLARE_EVENT_TABLE()
};


//Events

enum
{
	ID_btGuess=1001,
	ID_menuNew,
	ID_menuQuit,
    ID_menuNewIP,
	SOCKET_ID
};

BEGIN_EVENT_TABLE(ClientFrame, wxFrame)
	EVT_BUTTON(ID_btGuess, ClientFrame::OnClick_btGuess)
	EVT_MENU(ID_menuQuit, ClientFrame::OnClick_menuQuit)
	EVT_MENU(ID_menuNew, ClientFrame::OnClick_menuNew)
	EVT_MENU(ID_menuNewIP, ClientFrame::OnClick_menuNewIP)
	EVT_SOCKET(SOCKET_ID, ClientFrame::OnSocketEvent)
END_EVENT_TABLE() 




#endif

